<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var stoneGameVI = function (aliceValues, bobValues) {
      const arr = aliceValues.map((value, index) => [value + bobValues[index], index]).sort((a, b) => b[0] - a[0])
      let res = 0
      for (let i = 0; i < arr.length; i++) {
        if (i % 2 === 0) {
          res += aliceValues[arr[i][1]]
        } else {
          res -= bobValues[arr[i][1]]
        }
      }
      return res === 0 ? 0 : res > 0 ? 1 : -1
    };
    console.log(stoneGameVI(aliceValues = [1, 3], bobValues = [2, 1]))
  </script>
</body>

</html>